//
//  UsualQuestionCell.m
//  WE
//
//  Created by iMacOne on 15/11/24.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "UsualQuestionCell.h"
#import "Size.h"
#import "ToolUtil.h"
#define GREENCOLOR [UIColor colorWithRed:95 / 255.0 green:180 / 255.0 blue:53 / 255.0 alpha:1.0]

@interface UsualQuestionCell ()
@property (nonatomic, strong)UIImageView * iconImageV;
@property (nonatomic, strong)UILabel * aLbl;


@end
@implementation UsualQuestionCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
    
        self.iconImageV = [[UIImageView alloc] initWithFrame:CGRectMake(20, 5, 30, 30)];
        _iconImageV.backgroundColor = DEBUG_CLOLR;
        
        self.aLbl = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_iconImageV.frame) + 3, 10, [ToolUtil autoWidth:@"常见疾病及问题" width:0 height:20 num:12], 20)];
        _aLbl.font = FONT(12);
        _aLbl.text = @"常见疾病及问题";
        NSArray * arr = @[@"雀斑",@"空腔异味",@"减肥",@"肾虚",@"头疼",@"腰疼",@"腿疼痛"];
        int count = 0;
        float y = 0;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                float w = (WindowWidth - 60) / 3;
                UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
                btn.frame =CGRectMake(20 + j * 10 + j * w, CGRectGetMaxY(_aLbl.frame) + 10 + i*25 + i * 10 , w, 25);
                btn.titleLabel.textAlignment = NSTextAlignmentCenter;
                btn.titleLabel.font = FONT(12);
                btn.layer.masksToBounds = YES;
                btn.layer.cornerRadius = 3;
                btn.layer.borderWidth = 1;
                btn.layer.borderColor = GRAYCOLOR.CGColor;
                btn.tag = 100 + count;
                [btn setTitle:arr[count] forState:UIControlStateNormal];
                [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
                [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];

                y = CGRectGetMaxY(btn.frame);
                count++;
                [self.contentView addSubview:btn];

            }
        }
        UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.frame = CGRectMake(20, y + 10, WindowWidth - 40, 30);
        btn.tag = 200;
        [btn setTitle:@"更多疾病和问题>>" forState:UIControlStateNormal];
//        [btn setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
        btn.layer.masksToBounds = YES;
        btn.layer.cornerRadius = 3;
        btn.layer.borderWidth = 1;
        btn.layer.borderColor = GRAYCOLOR.CGColor;
        btn.titleLabel.font = FONT(14);
        btn.backgroundColor = GREENCOLOR;
        [self.contentView addSubview:btn];
        [self.contentView addSubview:_aLbl];
        [self.contentView addSubview:_iconImageV];

    }
    return self;
}
- (void)clickBtn:(UIButton *)btn
{
    [self.delegate doClickBtn:btn.tag cell:self];
}
@end
